home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / fstats.c < prev    next >
C/C++ Source or Header  |  1988-03-19  |  705b  |  35 lines

  1.  
  2. /* this entire mess -- IN ORDER, AS SHOWN! -- is required to use fstat()
  3. */
  4. #include <fcntl.h>
  5. #include <time.h>
  6. #include <sys/types.h>
  7. #include <sys/stat.h>
  8. #include <io.h>
  9. #include <stdio.h>
  10.  
  11.  
  12. /* dev_t, etc., are declared in sys/types.h
  13. struct stat {
  14.     dev_t st_dev;
  15.     ino_t st_ino;
  16.     unsigned short st_mode;
  17.     short st_nlink;
  18.     short st_uid;
  19.     short st_gid;
  20.     dev_t st_rdev;
  21.     off_t st_size;  <-- this is the one, and off_t is just a typedef for long!
  22.     time_t st_atime;
  23.     time_t st_mtime;
  24.     time_t st_ctime;
  25.     };
  26. */
  27.  
  28. long filesize( FILE *fptr )
  29. {
  30.      struct stat buf;
  31.      fstat( fileno(fptr), &buf );
  32.      return ( (long) buf.st_size );
  33. }
  34.  
  35.